$(function(){
	var taskId = getUrlParam('url');
	$("#sure").click(function(){
		$("#apply").attr("disabled",true);
		$.ajax({
			url:"../../applyTask.action",
			type:"post",
			data:{"taskid":taskId},
			dataType:"post",
			success:function(data)
			{
				$('#myModal').modal('show');
			},
		});
	});
	$.ajax({
		url:"../../getTaskInform.action",
		type:"post",
		dateType:"json",
		data:{"taskid":taskId},
		success:function(data)
		{
			
			$("#body").append('<div class="col-md-8 col-md-offset-3">'
					+'<h2>'+data.taskname+'</h2>'
					+'</div>'
					+'<div class="col-md-8 col-md-offset-3">'
					+'<h4>资金：'+data.commission+'元</h4>'
					+'</div>'
					+'<div class="col-md-8 col-md-offset-3">'
					+'<h4>起止时间：'+data.startDate+'~'+data.overDate+'</h4>'
					+'</div>'
					+'<div class="col-md-8 col-md-offset-3">'
					+'<h4>参与人数：'+data.joinnumber+'人</h4>'
					+'</div>'
					+'<div class="col-md-8 col-md-offset-3">'
					+'<h4>活动地点： '+data.city+'</h4>'
					+'</div>'
					+'<div class="col-md-8 col-md-offset-3">'
					+'<h4 id="picShow">图片:'
					+'</h4>'
					+'</div>'
					+'<div class="col-md-8 col-md-offset-3">'
					+'<h4>发布人： '+data.releasername+'</h4>'
					+'</div>'
					+'<div class="col-md-8 col-md-offset-4">'
					+'<button type="button" class="btn btn-primary btn-lg" data-toggle="modal" data-target="#myModal" id="apply">申请</button>'
					+'</div>');
			strs=data.picture.split("#"); 
			console.log(strs);
			for(var i=0;i<strs.length-1;i++)
				{
					$("#picShow").append('<img class="media-object img-rounded" src="/pic/'+strs[i]+'" id="id'+i+'" style="width: 50px;height:50px;"  onclick="changeSize(id)" alt="Responsive image">');
				}
		}
	});
	$.ajax({
		url:"../../getTaskAppInAccount.action",
		type:"post",
		dateType:"json",
		data:{"taskid":taskId},
		success:function(data)
		{
			$("#end").append('<label>已申请人数：'+data+'人</label>');
		}
	});
	$.ajax({
		url:"../../getTaskAppInform.action",
		type:"post",
		dateType:"json",
		data:{"taskid":taskId},
		success:function(data)
		{
			for(var i=0;i<data.length;i++)
			{
				$("#pitShow").append(
					'<a href="#"><img src="/pic/'+data[i].portrait+'" alt="Responsive image" class="img-circle" style="width:50px;height:50px;"></a>'
					);
			}
		}
	});
	});
var i=1;
function changeSize(id){  
	   var img = $("#"+id);  
	   var oWidth=img.width(); //取得图片的实际宽度  
	   var oHeight=img.height(); //取得图片的实际高度  
	   if(i==1)
		   {
		   img.width(oWidth+100);
		   img.height(oWidth+100);
		   i=2;
		   }
	   else
	   	{
		   img.width(oWidth-100);
		   img.height(oWidth-100);
		   i=1;
		  }
	   
	  // $(img).remove();
	}  

function getUrlParam(name) {
    var reg = new RegExp("(^|&)" + name + "=([^&]*)(&|$)"); //构造一个含有目标参数的正则表达式对象
    var r = window.location.search.substr(1).match(reg);  //匹配目标参数
    if (r != null) return unescape(r[2]); return null; //返回参数值
}

